﻿package com.netterminator.gwt.client.menu;

import com.smartgwt.client.types.SortArrow;
import com.smartgwt.client.types.TreeModelType;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;

/**
 * 菜单树类
 * 
 * @author SI YULONG
 *
 */
public class SideNavTree extends TreeGrid {

	//菜单ID后缀
    private String idSuffix = "";

    //菜单项
    private ExplorerTreeNode[] netTerminatorData = NetTerminatorData.getData(idSuffix);

    public SideNavTree() {
        setWidth100();
        setHeight100();
        setCustomIconProperty("icon");
        setAnimateFolderTime(100);
        setAnimateFolders(true);
        setAnimateFolderSpeed(1000);
        setNodeIcon("silk/application_view_list.png");
        setShowSortArrow(SortArrow.CORNER);
        setShowAllRecords(true);
        setLoadDataOnDemand(false);
        setCanSort(false);
        
        TreeGridField field = new TreeGridField();
        field.setCanFilter(true);
        field.setName("name");
        field.setTitle("<b>NetTerminator</b>");
        setFields(field);

        Tree tree = new Tree();
        tree.setModelType(TreeModelType.PARENT);
        tree.setNameProperty("name");
        tree.setOpenProperty("isOpen");
        tree.setIdField("nodeID");
        tree.setParentIdField("parentNodeID");
        tree.setRootValue("root" + idSuffix);

        tree.setData(netTerminatorData);

        setData(tree);
    }

    /**
     * 获取菜单项
     * @return NetTerminatorData菜单项数据
     */
    public ExplorerTreeNode[] getNetTerminatorData() {
        return netTerminatorData;
    }
}
